<!--
 * @Description: 教研活动记录表
 * @Autor: dyx
 * @Date: 2023-05-30 14:36:16
 * @LastEditTime: 2023-06-02 17:17:05
-->
<template>
  <div class="TISchedule">
    <div style="padding-right: 7px;">
      <el-button type="primary" style="float:right" @click="exportWord"
        >导出Word</el-button
      >
    </div>
    <div class="mytable" v-loading="loading">
      <div class="table_title">教研活动记录表</div>
      <table>
        <tr  >
          <td width="15%">
            时间
          </td>
          <td width="25%">
            <!-- <input type="text" v-model="dataForm.sj" style="width:100%" /> -->
            <el-date-picker
              v-model="dataForm.sj"
              type="date"
              value-format="yyyy-MM-dd"
              size="mini"
              style="width:100%"
            >
            </el-date-picker>
          </td>
          <td width="15%">
            地点
          </td>
          <td>
            <input type="text" v-model="dataForm.dd" style="width:100%" />
          </td>
        </tr>
        <tr  >
          <td width="130px">
            活动主题
          </td>
          <td colspan="3">
            <input type="text" v-model="dataForm.hdzt" style="width:100%" />
          </td>
        </tr>
        <tr  >
          <td width="130px">
            主持人
          </td>
          <td width="230px">
            <input type="text" v-model="dataForm.zcr" style="width:100%" />
          </td>
          <td width="150px">
            记录人
          </td>
          <td>
            <input type="text" v-model="dataForm.jlr" style="width:100%" />
          </td>
        </tr>
        <tr height="60px">
          <td width="130px">
            教师签到
          </td>
          <td colspan="3">
            <textarea
              v-model="dataForm.jsqd"
              style="width:100%; height:60px"
            ></textarea>
          </td>
        </tr>
        <tr height="260px">
          <td width="130px">
            活动记录
          </td>
          <td colspan="3">
            <textarea
              v-model="dataForm.hdjl"
              style="width:100%;height:260px"
            ></textarea>
          </td>
        </tr>
        <tr height="220px">
          <td width="130px">
            活动总结
          </td>
          <td colspan="3">
            <textarea
              v-model="dataForm.hdzj"
              style="width:100%;height:220px"
            ></textarea>
          </td>
        </tr>
      </table>
    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
import Textarea from "@/components/Generator/index/RightComponents/Textarea.vue";
export default {
  components: { Textarea },
  name: "TISchedule",
  data() {
    return {
      loading: true,
      dataForm: {},
      list: []
    };
  },
  created() {},
  methods: {
    init(id) {
      this.loading = true;
      request({
        url: "/api/class_archives/generateA15/" + id+`?organizeId=${this.$store.getters.organizeId}`,
        method: "get"
      }).then(res => {
        this.dataForm = res.data;
        // console.log(this.dataForm, 147);
        this.loading = false;
      });
    },
    exportWord() {
      for (let key in this.dataForm) {
        if (Array.isArray(this.dataForm[key])) {
          if (key == "childrenVOList") {
            this.dataForm[key].forEach(item => {
              for (let key2 in item) {
                if (item[key2] == null) {
                  item[key2] = "";
                }
              }
            });
          } else {
            this.dataForm[key] = this.dataForm[key].join(",");
          }
        } else if (this.dataForm[key] == null) {
          this.dataForm[key] = "";
        }
      }
      this.dataForm.organizeId = this.$store.getters.organizeId;
      request({
        responseType: "blob",
        url: "/api/class_archives/generateA15Export",
        method: "post",
        data: this.dataForm
      }).then(res => {
        // console.log(res, 123);
        var debug = res;
        if (debug) {
          var a = document.createElement("a");
          a.download = "教研活动记录表.docx";
          a.style.display = "none";
          var blob = new Blob([debug], { type: "application/x-msdownload" });
          a.href = URL.createObjectURL(blob);
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        }
      });
    }
  }
};
</script>
<style scoped lang="scss">
// 引入公共样式
@import "./TABLESTYLE.scss";
// input {
//   border: 1px solid #000 !important;
// }
// textarea {
//   border: 1px solid #000 !important;
// }
</style>
